
main().then(res => {
  console.log('main then', res);
}).catch(function(e) {
  console.log('top', e);
});

async function main() {
  try {
    loadImage();
    const [error, data] = await loadConfig().then(data => {
      return [null, data];
    }).catch(e => {
      return [e.message, null];
    })
    console.log(error)
  } catch (e) {
    console.log('main', e);
  }
}

function loadImage(){
  return new Promise((resolve, reject) => {
    setTimeout(reject, 1000, 'network error');
  });
}

async function loadConfig(){
  throw new Error('logic bug');
  await wait();
  console.log('config ok');
}

function wait(){
  return new Promise((resolve, reject) => {
    setTimeout(resolve, 1000);
  });
}